package com.example.try_with_resources;


public class CustomAutoClosable implements AutoCloseable{
    private String src;

    public CustomAutoClosable(String src) {
        this.src = src;
    }

    public void open() {
        if ("".equals(src))
            throw new UnsupportedOperationException();
        System.out.println("open src: " + src);
    }

    @Override
    public void close() throws Exception {
        if ("".equals(src))
            throw new RuntimeException("src is empty");
        System.out.println("close src: " + src);
    }

    public void doClose() {
        throw new RuntimeException("close error");
    }
}
